<script setup>
const props = defineProps(['formData', 'form'])
const form = props.form
const rules = Object.keys(props.formData).filter(key => props.formData[key].rules)
</script>

<template>
  <el-form :rules="rules">
    <template v-for="(item, key) in formData" :key="key">
      <!-- 下拉框 -->
      <el-form-item :prop="key" :label="item.label" v-if="item.select">
        <el-select v-model="form[key]" :placeholder="item.placeholder">
          <el-option :label="opt.label" :value="opt.value" v-for="opt in item.options"/>
        </el-select>
      </el-form-item>
      <!-- 单行输入 -->
      <el-form-item :prop="key" :label="formData[key].label" :placeholder="item.placeholder" v-else>
        <el-input v-model="form[key]" type="text" />
      </el-form-item>
    </template>
  </el-form>
</template>